import { NextResponse } from "next/server"

/**
 * 获取歌曲列表
 *
 * @route GET /api/songs
 * @param {number} page - 页码，默认为1
 * @param {number} limit - 每页数量，默认为20
 *
 * @returns {Object} 返回歌曲列表和分页信息
 *
 * 请求示例:
 * GET /api/songs?page=1&limit=20
 *
 * 返回示例:
 * {
 *   "success": true,
 *   "data": [
 *     {
 *       "id": "1",
 *       "title": "一念封神",
 *       "artist": "张碧晨",
 *       "duration": "03:50"
 *     },
 *     // ... 更多歌曲
 *   ],
 *   "pagination": {
 *     "currentPage": 1,
 *     "totalPages": 10,
 *     "totalItems": 200
 *   }
 * }
 */
export async function GET(request: Request) {
  const { searchParams } = new URL(request.url)
  const page = Number.parseInt(searchParams.get("page") || "1")
  const limit = Number.parseInt(searchParams.get("limit") || "20")

  // 实现获取歌曲列表逻辑
  return NextResponse.json({
    success: true,
    data: [
      { id: "1", title: "一念封神", artist: "张碧晨", duration: "03:50" },
      // ... 更多歌曲
    ],
    pagination: {
      currentPage: page,
      totalPages: 10,
      totalItems: 200,
    },
  })
}

/**
 * 获取歌曲详情
 *
 * @route GET /api/songs/[id]
 * @param {string} id - 歌曲ID
 *
 * @returns {Object} 返回歌曲详细信息
 *
 * 请求示例:
 * GET /api/songs/1
 *
 * 返回示例:
 * {
 *   "success": true,
 *   "data": {
 *     "id": "1",
 *     "title": "一念封神",
 *     "artist": "张碧晨",
 *     "album": "一念封神",
 *     "duration": "03:50",
 *     "releaseDate": "2023-05-20",
 *     "lyrics": "词：王洋\n曲：陈禹...",
 *     "coverUrl": "https://example.com/cover/1.jpg"
 *   }
 * }
 */
export async function GET(request: Request, { params }: { params: { id: string } }) {
  const id = params.id

  // 实现获取歌曲详情逻辑
  return NextResponse.json({
    success: true,
    data: {
      id: "1",
      title: "一念封神",
      artist: "张碧晨",
      album: "一念封神",
      duration: "03:50",
      releaseDate: "2023-05-20",
      lyrics: "词：王洋\n曲：陈禹...",
      coverUrl: "https://example.com/cover/1.jpg",
    },
  })
}

